<?php

//轮播图

namespace App\Http\Controllers\Property;


use App\Common\json;
use App\Common\SmsClient;
use App\Http\Controllers\Controller;
use App\Libraries\upload;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;


class RotationController extends Controller{

    public function SelectRotation(Request $request){
        if($request ->isMethod('post')){
            $village_id       = $request ->input('village_id');
            $data     = DB::table('rotation')
                      ->select('rotation_image','image_url')

                      ->where('rotation_village',$village_id)
                      ->get();
            foreach ($data as $value){
                if(empty($value ->rotation_image)){
                    $rotation_image  =[];
                }else{
                    $rotation_image  = $value ->rotation_image;
                }
                if(empty($value ->image_url)){
                    $image_url  =[];
                }else{
                    $image_url  = $value ->image_url;
                }
                $dd[]    = array(
                    'rotation_image'    =>$rotation_image,
                    'image_url'         =>$image_url
                );
            }

            if($data  == true){
                return json::json('success','获取轮播图成功',$dd);
            }else{
                return json::json('failure','',[]);
            }
        }
    }


}